﻿using MetroFramework.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Database.Model;
using Database.Control;
using System.Globalization;
using Database;


namespace ProjectZero.View
{
    public partial class CadastroEmpresasFiltro : MetroForm
    {
        public CadastroEmpresasFiltro()
        {
            InitializeComponent();
            tela();
        }

        private void tela()
        {
            Entities context = new Entities();

            //monta grid
            var v = CAD_EMPRESA.GridFiltroEmpresa();
            this.grdEmpresas.DataSource = v;
        }

        private void btnInserir_Click(object sender, EventArgs e)
        {
            CadastroEmpresa c = new CadastroEmpresa();
            c.Show();
           
        }


        private Int64 retornaId()
        {
            try
            {
                Int64 id = Convert.ToInt64(grdEmpresas.CurrentRow.Cells["id"].Value.ToString());
                return id;
            }
            catch 
            {
                return 0;
            }

        }

        private void grdEmpresas_DoubleClick(object sender, EventArgs e)
        {
            CadastroEmpresa c = new CadastroEmpresa(retornaId());
            c.Show();
        }

    }
}
